home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / xlisp14.arc / XLISP.DOC next >
Text File  |  1985-03-14  |  55KB  |  1,359 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.             XLISP: An Experimental Object Oriented Language
  7.  
  8.                               Version 1.4
  9.  
  10.                             January 1, 1985
  11.  
  12.  
  13.                                    by
  14.                                David Betz
  15.                            114 Davenport Ave.
  16.                          Manchester, NH  03103
  17.  
  18.                          (603) 625-4691 (home)
  19.  
  20.  
  21.  
  22.       XLISP: An Experimental Object Oriented Language                 Page 2
  23.       TABLE OF CONTENTS
  24.  
  25.  
  26.               1.0     INTRODUCTION . . . . . . . . . . . . . . . . . . . . 3
  27.               2.0     A NOTE FROM THE AUTHOR . . . . . . . . . . . . . . . 4
  28.               3.0     XLISP COMMAND LOOP . . . . . . . . . . . . . . . . . 5
  29.               4.0     BREAK COMMAND LOOP . . . . . . . . . . . . . . . . . 6
  30.               5.0     DATA TYPES . . . . . . . . . . . . . . . . . . . . . 7
  31.               6.0     THE EVALUATOR  . . . . . . . . . . . . . . . . . . . 8
  32.               7.0     LEXICAL CONVENTIONS  . . . . . . . . . . . . . . . . 9
  33.               8.0     OBJECTS  . . . . . . . . . . . . . . . . . . . . .  10
  34.               9.0     SYMBOLS  . . . . . . . . . . . . . . . . . . . . .  13
  35.               10.0    EVALUATION FUNCTIONS . . . . . . . . . . . . . . .  14
  36.               11.0    SYMBOL FUNCTIONS . . . . . . . . . . . . . . . . .  15
  37.               12.0    PROPERTY LIST FUNCTIONS  . . . . . . . . . . . . .  17
  38.               13.0    LIST FUNCTIONS . . . . . . . . . . . . . . . . . .  18
  39.               14.0    DESTRUCTIVE LIST FUNCTIONS . . . . . . . . . . . .  21
  40.               15.0    PREDICATE FUNCTIONS  . . . . . . . . . . . . . . .  22
  41.               16.0    CONTROL FUNCTIONS  . . . . . . . . . . . . . . . .  24
  42.               17.0    LOOPING FUNCTIONS  . . . . . . . . . . . . . . . .  25
  43.               18.0    THE PROGRAM FEATURE  . . . . . . . . . . . . . . .  26
  44.               19.0    DEBUGGING AND ERROR HANDLING . . . . . . . . . . .  27
  45.               20.0    ARITHMETIC FUNCTIONS . . . . . . . . . . . . . . .  28
  46.               21.0    BITWISE LOGICAL FUNCTIONS  . . . . . . . . . . . .  29
  47.               22.0    RELATIONAL FUNCTIONS . . . . . . . . . . . . . . .  30
  48.               23.0    STRING FUNCTIONS . . . . . . . . . . . . . . . . .  31
  49.               24.0    INPUT/OUTPUT FUNCTIONS . . . . . . . . . . . . . .  32
  50.               25.0    FILE I/O FUNCTIONS . . . . . . . . . . . . . . . .  33
  51.               26.0    SYSTEM FUNCTIONS . . . . . . . . . . . . . . . . .  34
  52.  
  53.  
  54.  
  55.       XLISP: An Experimental Object Oriented Language                 Page 3
  56.       INTRODUCTION
  57.  
  58.  
  59.       1.0  INTRODUCTION
  60.  
  61.       XLISP is an experimental programming language combining some
  62.       of  the  features  of LISP with an object oriented extension
  63.       capability.  It was  implemented  to  allow  experimentation
  64.       with  object oriented programming on small computers.  There
  65.       are currently implementations running on  the  PDP-11  under
  66.       UNIX  V7, on the VAX-11 under VAX/VMS and Berkeley VAX/UNIX,
  67.       and on the 8088/8086 under CP/M-86 or MS-DOS.  A version  is
  68.       currently  being  developed for the 68000 under CP/M-68K and
  69.       for the Apple Macintosh.  It is completely  written  in  the
  70.       programming  language  'C'  and is easily extended with user
  71.       written built-in functions and classes.  It is available  in
  72.       source   form   free  of  charge  to  non-commercial  users.
  73.       Prospective commercial users should contact the  author  for
  74.       permission to use XLISP.
  75.  
  76.       Many traditional LISP functions are built  into  XLISP.   In
  77.       addition,  XLISP defines the objects 'Object' and 'Class' as
  78.       primitives.   'Object'  is  the  only  class  that  has   no
  79.       superclass  and  hence  is  the  root of the class heirarchy
  80.       tree.  'Class'  is  the  class  of  which  all  classes  are
  81.       instances  (it  is  the  only  object that is an instance of
  82.       itself).
  83.  
  84.       This document is intended  to  be  a  brief  description  of
  85.       XLISP.    It   assumes  some  knowledge  of  LISP  and  some
  86.       understanding   of   the   concepts   of   object   oriented
  87.       programming.
  88.  
  89.       Version 1.2 of XLISP differs from  version  1.1  in  several
  90.       ways.   It  supports  many  more Lisp functions.  Also, many
  91.       version 1.1  functions  have  been  renamed  and/or  changed
  92.       slightly  to follow traditional Lisp usage.  One of the most
  93.       frequently reported problems in version  1.1  resulted  from
  94.       many  functions being named after their equivilent functions
  95.       in the C language.  This turned  out  to  be  confusing  for
  96.       people who were trying to learn XLISP using traditional LISP
  97.       texts as references.  Version 1.2 renames these functions to
  98.       be  compatible  with  more  traditional  dialects  of  LISP.
  99.       Version 1.3 introduces many new  LISP  functions  and  moves
  100.       closer  to the goal of being compatible with the Common Lisp
  101.       standard.  Version 1.4 introduces user  error  handling  and
  102.       breakpoint  support  as  well as more Common Lisp compatible
  103.       functions.
  104.  
  105.       A recommended text for learning LISP programming is the book
  106.       "LISP"  by Winston and Horn and published by Addison Wesley.
  107.       The first edition of this book is based on MacLisp  and  the
  108.       second  edition is based on Common Lisp.  Future versions of
  109.       XLISP will continue to migrate  towards  compatibility  with
  110.       Common Lisp.
  111.  
  112.  
  113.  
  114.       XLISP: An Experimental Object Oriented Language                 Page 4
  115.       A NOTE FROM THE AUTHOR
  116.  
  117.  
  118.       2.0  A NOTE FROM THE AUTHOR
  119.  
  120.       If you have any problems with XLISP, feel free to contact me
  121.       for  help  or  advice.   Please remember that since XLISP is
  122.       available in source form in  a  high  level  language,  many
  123.       users  have  been  making versions available on a variety of
  124.       machines.  If you call to report a problem with  a  specific
  125.       version,  I may not be able to help you if that version runs
  126.       on a machine to which I don't have access.  Please have  the
  127.       version  number  of the version that you are running readily
  128.       accessible before calling me.
  129.  
  130.       If you find a bug  in  XLISP,  first  try  to  fix  the  bug
  131.       yourself  using  the  source  code  provided.   If  you  are
  132.       successful in fixing the bug, send the bug report along with
  133.       the  fix to me.  If you don't have access to a C compiler or
  134.       are unable to fix a bug, please send the bug  report  to  me
  135.       and I'll try to fix it.
  136.  
  137.       Any suggestions for improvements  will  be  welcomed.   Feel
  138.       free  to  extend  the  language  in  whatever way suits your
  139.       needs.  However, PLEASE DO  NOT  RELEASE  ENHANCED  VERSIONS
  140.       WITHOUT  CHECKING  WITH  ME  FIRST!!  I would like to be the
  141.       clearing house for new features added to XLISP.  If you want
  142.       to  add  features for your own personal use, go ahead.  But,
  143.       if you want to distribute your enhanced version, contact  me
  144.       first.  Please remember that the goal of XLISP is to provide
  145.       a language to learn and  experiment  with  LISP  and  object
  146.       oriented programming on small computers.
  147.  
  148.  
  149.  
  150.       XLISP: An Experimental Object Oriented Language                 Page 5
  151.       XLISP COMMAND LOOP
  152.  
  153.  
  154.       3.0  XLISP COMMAND LOOP
  155.  
  156.       When XLISP is started, it first  tries  to  load  "init.lsp"
  157.       from  the  default directory.  It then loads any files named
  158.       as parameters on the command line (after appending ".lsp" to
  159.       their names).  It then issues the following prompt:
  160.  
  161.       >
  162.  
  163.       This indicates that XLISP is waiting for an expression to be
  164.       typed.   When  an  incomplete expression has been typed (one
  165.       where the left and right parens don't match)  XLISP  changes
  166.       its prompt to:
  167.  
  168.       n>
  169.  
  170.       where n is an integer indicating how  many  levels  of  left
  171.       parens remain unclosed.
  172.  
  173.       When a complete expression has been entered, XLISP  attempts
  174.       to  evaluate  that  expression.  If the expression evaluates
  175.       successfully, XLISP prints the result of the evaluation  and
  176.       then  returns  to  the  initial  prompt  waiting for another
  177.       expression to be typed.
  178.  
  179.       Input can be aborted at any time by typing the CONTROL-G key
  180.       (it may be necessary to follow CONTROL-G by RETURN).
  181.  
  182.  
  183.  
  184.       XLISP: An Experimental Object Oriented Language                 Page 6
  185.       BREAK COMMAND LOOP
  186.  
  187.  
  188.       4.0  BREAK COMMAND LOOP
  189.  
  190.       When  XLISP  encounters  an  error   while   evaluating   an
  191.       expression, it attempts to handle the error in the following
  192.       way:
  193.  
  194.       If  the  symbol  '*breakenable*'  is   true,   the   message
  195.       corresponding  to  the  error  is  printed.  If the error is
  196.       correctable, the correction  message  is  printed.   If  the
  197.       symbol '*tracenable*' is true, a trace back is printed.  The
  198.       number of entries printed depends on the value of the symbol
  199.       '*tracelimit*'.   If  this  symbol is set to something other
  200.       than a number, the  entire  trace  back  stack  is  printed.
  201.       XLISP  then  enters a read/eval/print loop to allow the user
  202.       to examine the state of the interpreter in  the  context  of
  203.       the  error.   This  loop  differs  from the normal top-leval
  204.       read/eval/print loop in that if the user  types  the  symbol
  205.       'continue' XLISP will continue from a correctable error.  If
  206.       the user types the symbol 'quit' XLISP will abort the  break
  207.       loop  and return to the top level or the next lower numbered
  208.       break loop.  When in a break loop, XLISP prefixes the  break
  209.       level to the normal prompt.
  210.  
  211.       If the symbol '*breakenable*' is  nil,  XLISP  looks  for  a
  212.       surrounding   errset  function.   If  one  is  found,  XLISP
  213.       examines the value of the print flag.  If this flag is true,
  214.       the error message is printed.  In any case, XLISP causes the
  215.       errset function call to return nil.
  216.  
  217.       If there is no surrounding errset function, XLISP prints the
  218.       error message and returns to the top level.
  219.  
  220.  
  221.  
  222.       XLISP: An Experimental Object Oriented Language                 Page 7
  223.       DATA TYPES
  224.  
  225.  
  226.       5.0  DATA TYPES
  227.  
  228.       There are several different data types  available  to  XLISP
  229.       programmers.
  230.  
  231.  
  232.             o  lists
  233.  
  234.             o  symbols
  235.  
  236.             o  strings
  237.  
  238.             o  integers
  239.  
  240.             o  objects
  241.  
  242.             o  file pointers
  243.  
  244.             o  subrs/fsubrs (built-in functions)
  245.  
  246.       Another data type is the stream.  A stream is  a  list  node
  247.       whose car points to the head of a list of integers and whose
  248.       cdr points to the last list node  of  the  list.   An  empty
  249.       stream  is  a  list node whose car and cdr are nil.  Each of
  250.       the integers in the  list  represents  a  character  in  the
  251.       stream.   When  a character is read from a stream, the first
  252.       integer from the head of the list is removed  and  returned.
  253.       When  a  character  is  written  to  a  stream,  the integer
  254.       representing the character code of the character is appended
  255.       to  the  end of the list.  When a function indicates that it
  256.       takes an input source as a  parameter,  this  parameter  can
  257.       either  be  an  input  file pointer or a stream.  Similarly,
  258.       when a function indicates that it takes an output sink as  a
  259.       parameter,  this  parameter  can  either  be  an output file
  260.       pointer or a stream.
  261.  
  262.  
  263.  
  264.       XLISP: An Experimental Object Oriented Language                 Page 8
  265.       THE EVALUATOR
  266.  
  267.  
  268.       6.0  THE EVALUATOR
  269.  
  270.       The process of evaluation in XLISP:
  271.  
  272.             o  Integers,  strings,  objects,  file  pointers,  and
  273.                subrs evaluate to themselves
  274.  
  275.             o  Symbols evaluate to the value associated with their
  276.                current binding
  277.  
  278.             o  Lists are evaluated by evaluating the first element
  279.                of the list
  280.  
  281.                 o  If it evaluates to a subr, the  remaining  list
  282.                    elements  are  evaluated and the subr is called
  283.                    with these evaluated expressions as arguments.
  284.  
  285.                 o  If it evaluates  to  an  fsubr,  the  fsubr  is
  286.                    called  using  the  remaining  list elements as
  287.                    arguments  (they  are  evaluated  by  the  subr
  288.                    itself if necessary)
  289.  
  290.                 o  If it evaluates to a list and the  car  of  the
  291.                    list  is  'lambda', the remaining list elements
  292.                    are evaluated and the resulting expressions are
  293.                    bound  to  the  formal  arguments of the lambda
  294.                    expression.   The  body  of  the  function   is
  295.                    executed within this new binding environment.
  296.  
  297.                 o  If it evaluates to a list and the  car  of  the
  298.                    list  is  'macro',  the remaining list elements
  299.                    are bound to the formal arguments of the  macro
  300.                    expression.    The  body  of  the  function  is
  301.                    executed within this new  binding  environment.
  302.                    The result of this evaluation is considered the
  303.                    macro expansion.  This result is then evaluated
  304.                    in place of the original expression.
  305.  
  306.                 o  If it evaluates to an object, the  second  list
  307.                    element  is  evaluated  and  used  as a message
  308.                    selector.  The message formed by combining  the
  309.                    selector  with the values of the remaining list
  310.                    elements is sent to the object.
  311.  
  312.  
  313.  
  314.  
  315.  
  316.       XLISP: An Experimental Object Oriented Language                 Page 9
  317.       LEXICAL CONVENTIONS
  318.  
  319.  
  320.       7.0  LEXICAL CONVENTIONS
  321.  
  322.       The following conventions are followed when  entering  XLISP
  323.       programs:
  324.  
  325.       Comments in XLISP code begin with a semi-colon character and
  326.       continue to the end of the line.
  327.  
  328.       Symbol names  in  XLISP  can  consist  of  any  sequence  of
  329.       non-blank printable characters except the following:
  330.  
  331.               ( ) ' ` , " ;
  332.  
  333.       Upper and lower case characters are distinct.   The  symbols
  334.       'CAR' and 'car' are not the same.  The names of all built-in
  335.       functions are in lower case.   The  names  of  all  built-in
  336.       objects  are  lower  case  with  an initial capital.  Symbol
  337.       names must not begin with a digit.
  338.  
  339.       Integer literals consist of a sequence of digits  optionally
  340.       beginning with a '+' or '-'.  The range of values an integer
  341.       can represent is limited by the size of a  C  'int'  on  the
  342.       machine that XLISP is running on.
  343.  
  344.       Literal strings are sequences of  characters  surrounded  by
  345.       double  quotes.   Within quoted strings the '\' character is
  346.       used to allow non-printable characters to be included.   The
  347.       codes recognized are:
  348.  
  349.               \\      means the character '\'
  350.               \n      means newline
  351.               \t      means tab
  352.               \r      means return
  353.               \e      means escape
  354.               \nnn    means the character whose octal code is nnn
  355.  
  356.       XLISP defines several useful read macros:
  357.  
  358.               '<expr>  == (quote <expr>)
  359.               #'<expr> == (function <expr>)
  360.               `<expr>  == (backquote <expr>)
  361.               ,<expr>  == (comma <expr>)
  362.               ,@<expr> == (comma-at <expr>)
  363.  
  364.  
  365.  
  366.       XLISP: An Experimental Object Oriented Language                Page 10
  367.       OBJECTS
  368.  
  369.  
  370.       8.0  OBJECTS
  371.  
  372.       Definitions:
  373.  
  374.             o  selector - a symbol used to select  an  appropriate
  375.                method
  376.  
  377.             o  message - a selector and a list of actual arguments
  378.  
  379.             o  method - the code that implements a message
  380.  
  381.       Since XLISP was  created  to  provide  a  simple  basis  for
  382.       experimenting  with  object oriented programming, one of the
  383.       primitive data types included was 'object'.   In  XLISP,  an
  384.       object  consists of a data structure containing a pointer to
  385.       the object's class as well as a list containing  the  values
  386.       of the object's instance variables.
  387.  
  388.       Officially, there is no way to see inside an object (look at
  389.       the  values  of  its  instance  variables).  The only way to
  390.       communicate with an object is by sending it a message.  When
  391.       the  XLISP  evaluator  evaluates  a  list the value of whose
  392.       first element is an object, it interprets the value  of  the
  393.       second  element  of the list (which must be a symbol) as the
  394.       message selector.  The evaluator determines the class of the
  395.       receiving object and attempts to find a method corresponding
  396.       to the message selector in the set of messages  defined  for
  397.       that  class.   If  the  message is not found in the object's
  398.       class and the class has a super-class, the search  continues
  399.       by  looking  at  the  messages  defined for the super-class.
  400.       This process continues from  one  super-class  to  the  next
  401.       until  a  method  for the message is found.  If no method is
  402.       found, an error occurs.
  403.  
  404.       When a method is found, the evaluator  binds  the  receiving
  405.       object  to  the  symbol 'self', binds the class in which the
  406.       method was found to the symbol 'msgclass', and evaluates the
  407.       method  using the remaining elements of the original list as
  408.       arguments  to  the  method.   These  arguments  are   always
  409.       evaluated prior to being bound to their corresponding formal
  410.       arguments.  The result of evaluating the method becomes  the
  411.       result of the expression.
  412.  
  413.  
  414.  
  415.       XLISP: An Experimental Object Oriented Language                Page 11
  416.       OBJECTS
  417.  
  418.  
  419.       Classes:
  420.  
  421.       Object  THE TOP OF THE CLASS HEIRARCHY
  422.  
  423.           Messages:
  424.  
  425.               show    SHOW AN OBJECT'S INSTANCE VARIABLES
  426.                   returns     the object
  427.  
  428.               class   RETURN THE CLASS OF AN OBJECT
  429.                   returns     the class of the object
  430.  
  431.               isnew   THE DEFAULT OBJECT INITIALIZATION ROUTINE
  432.                   returns     the object
  433.  
  434.               sendsuper <sel> [<args>...] SEND SUPERCLASS A MESSAGE
  435.                   <sel>       the message selector
  436.                   <args>      the message arguments
  437.                   returns     the result of sending the message
  438.  
  439.  
  440.  
  441.       XLISP: An Experimental Object Oriented Language                Page 12
  442.       OBJECTS
  443.  
  444.  
  445.       Class   THE CLASS OF ALL OBJECT CLASSES (including itself)
  446.  
  447.           Messages:
  448.  
  449.               new     CREATE A NEW INSTANCE OF A CLASS
  450.                   returns     the new class object
  451.  
  452.               isnew [<scls>]  INITIALIZE A NEW CLASS
  453.                   <scls>      the superclass
  454.                   returns     the new class object
  455.  
  456.               answer <msg> <fargs> <code>     ADD A MESSAGE TO A CLASS
  457.                   <msg>       the message symbol
  458.                   <fargs>     the formal argument list
  459.                                 this list is of the form:
  460.                                   (<farg>...
  461.                                    [&optional <oarg>...]
  462.                                    [&rest <rarg>]
  463.                                    [&aux <aux>...])
  464.                                 where
  465.                                   <farg>   a formal argument
  466.                                   <oarg>   an optional argument (default is nil)
  467.                                   <rarg>   bound to the rest of the arguments
  468.                                   <aux>    a auxiliary variable (set to nil)
  469.                   <code>      a list of executable expressions
  470.                   returns     the object
  471.  
  472.               ivars <vars>    DEFINE THE LIST OF INSTANCE VARIABLES
  473.                   <vars>      the list of instance variable symbols
  474.                   returns     the object
  475.  
  476.               cvars <vars>    DEFINE THE LIST OF CLASS VARIABLES
  477.                   <vars>      the list of class variable symbols
  478.                   returns     the object
  479.  
  480.  
  481.       When a new instance of a class is  created  by  sending  the
  482.       message  'new'  to  an  existing  class, the message 'isnew'
  483.       followed by whatever parameters were  passed  to  the  'new'
  484.       message is sent to the newly created object.
  485.  
  486.       When a new class is created by sending the 'new' message  to
  487.       the  object  'Class', an optional parameter may be specified
  488.       indicating  the  superclass  of  the  new  class.   If  this
  489.       parameter  is  omitted,  the new class will be a subclass of
  490.       'Object'.  A class inherits all  instance  variables,  class
  491.       variables, and methods from its super-class.
  492.  
  493.  
  494.  
  495.       XLISP: An Experimental Object Oriented Language                Page 13
  496.       SYMBOLS
  497.  
  498.  
  499.       9.0  SYMBOLS
  500.  
  501.  
  502.             o  self  -  the  current  object  (within  a   message
  503.                context)
  504.  
  505.             o  msgclass - the class in which  the  current  method
  506.                was found
  507.  
  508.             o  *oblist* - the object list
  509.  
  510.             o  *keylist* - the keyword list
  511.  
  512.             o  *standard-input* - the standard input file
  513.  
  514.             o  *standard-output* - the standard output file
  515.  
  516.             o  *breakenable* - flag controlling entering the break
  517.                loop on errors
  518.  
  519.             o  *tracenable* - flag controlling trace back printout
  520.                on errors and breaks
  521.  
  522.             o  *tracelimit* - maximum number of  levels  of  trace
  523.                back information printed on errors and breaks
  524.  
  525.             o  *evalhook* -  user  substitute  for  the  evaluator
  526.                function
  527.  
  528.             o  *applyhook* - (not yet implemented)
  529.  
  530.             o  *unbound* - indicator for unbound symbols
  531.  
  532.  
  533.  
  534.  
  535.       XLISP: An Experimental Object Oriented Language                Page 14
  536.       EVALUATION FUNCTIONS
  537.  
  538.  
  539.       10.0  EVALUATION FUNCTIONS
  540.  
  541.       (eval <expr>)  EVALUATE AN XLISP EXPRESSION
  542.           <expr>      the expression to be evaluated
  543.           returns     the result of evaluating the expression
  544.  
  545.       (apply <fun> <args>)  APPLY A FUNCTION TO A LIST OF ARGUMENTS
  546.           <fun>       the function to apply (or function symbol)
  547.           <args>      the argument list
  548.           returns     the result of applying the function to the argument list
  549.  
  550.       (funcall <fun> <arg>...)  CALL A FUNCTION WITH ARGUMENTS
  551.           <fun>       the function to call (or function symbol)
  552.           <arg>       arguments to pass to the function
  553.           returns     the result of calling the function with the arguments
  554.  
  555.       (quote <expr>)  RETURN AN EXPRESSION UNEVALUATED
  556.           <expr>      the expression to be quoted (quoted)
  557.           returns     <expr> unevaluated
  558.  
  559.       (function <expr>)  QUOTE A FUNCTION (THIS IS THE SAME AS QUOTE)
  560.           <expr>      the function to be quoted (quoted)
  561.           returns     <expr> unevaluated
  562.  
  563.       (backquote <expr>)  FILL IN A TEMPLATE
  564.           <expr>      the template
  565.           returns     a copy of the template with comma and comma-at expressions
  566.                       expanded (see the Common Lisp reference manual)
  567.  
  568.  
  569.  
  570.       XLISP: An Experimental Object Oriented Language                Page 15
  571.       SYMBOL FUNCTIONS
  572.  
  573.  
  574.       11.0  SYMBOL FUNCTIONS
  575.  
  576.       (set <sym> <expr>)  SET THE VALUE OF A SYMBOL
  577.           <sym>       the symbol being set
  578.           <expr>      the new value
  579.           returns     the new value
  580.  
  581.       (setq [<sym> <expr>]...)  SET THE VALUE OF A SYMBOL
  582.           <sym>       the symbol being set (quoted)
  583.           <expr>      the new value
  584.           returns     the new value
  585.  
  586.       (setf [<place> <expr>]...)  SET THE VALUE OF A FIELD
  587.           <place>     the field specifier (quoted):
  588.                           <sym>                set the value of a symbol
  589.                           (car <expr>)         set the car of a list node
  590.                           (cdr <expr>)         set the cdr of a list node
  591.                           (get <sym> <prop>)   set the value of a property
  592.                           (symbol-value <sym>) set the value of a symbol
  593.                           (symbol-plist <sym>) set the property list of a symbol
  594.           <value>     the new value
  595.           returns     the new value
  596.  
  597.       (defun <sym> <fargs> <expr>...)  DEFINE A FUNCTION
  598.       (defmacro <sym> <fargs> <expr>...)  DEFINE A MACRO
  599.           <sym>       symbol being defined (quoted)
  600.           <fargs>     list of formal arguments (quoted)
  601.                         this list is of the form:
  602.                           (<farg>...
  603.                            [&optional <oarg>...]
  604.                            [&rest <rarg>]
  605.                            [&aux <aux>...])
  606.                         where
  607.                           <farg>      is a formal argument
  608.                           <oarg>      is an optional argument (default is nil)
  609.                           <rarg>      bound to the rest of the arguments
  610.                           <aux>       is an auxiliary variable (set to nil)
  611.           <expr>      expressions constituting the body of the
  612.                       function (quoted)
  613.           returns     the function symbol
  614.  
  615.       (gensym [<tag>])  GENERATE A SYMBOL
  616.           <tag>       string or number
  617.           returns     the new symbol
  618.  
  619.       (intern <pname>)  MAKE AN INTERNED SYMBOL
  620.           <pname>     the symbol's print name string
  621.           returns     the new symbol
  622.  
  623.       (make-symbol <pname>)  MAKE AN UNINTERNED SYMBOL
  624.           <pname>     the symbol's print name string
  625.           returns     the new symbol
  626.  
  627.  
  628.  
  629.       XLISP: An Experimental Object Oriented Language                Page 16
  630.       SYMBOL FUNCTIONS
  631.  
  632.  
  633.       (symbol-name <sym>)  GET THE PRINT NAME OF A SYMBOL
  634.           <sym>       the symbol
  635.           returns     the symbol's print name
  636.  
  637.       (symbol-value <sym>)  GET THE VALUE OF A SYMBOL
  638.           <sym>       the symbol
  639.           returns     the symbol's value
  640.  
  641.       (symbol-plist <sym>)  GET THE PROPERTY LIST OF A SYMBOL
  642.           <sym>       the symbol
  643.           returns     the symbol's property list
  644.  
  645.  
  646.  
  647.       XLISP: An Experimental Object Oriented Language                Page 17
  648.       PROPERTY LIST FUNCTIONS
  649.  
  650.  
  651.       12.0  PROPERTY LIST FUNCTIONS
  652.  
  653.       (get <sym> <prop>)  GET THE VALUE OF A PROPERTY
  654.           <sym>       the symbol
  655.           <prop>      the property symbol
  656.           returns     the property value or nil
  657.  
  658.       (remprop <prop> <sym>)  REMOVE A PROPERTY
  659.           <sym>       the symbol
  660.           <prop>      the property symbol
  661.           returns     nil
  662.  
  663.  
  664.  
  665.       XLISP: An Experimental Object Oriented Language                Page 18
  666.       LIST FUNCTIONS
  667.  
  668.  
  669.       13.0  LIST FUNCTIONS
  670.  
  671.       (car <expr>)  RETURN THE CAR OF A LIST NODE
  672.           <expr>      the list node
  673.           returns     the car of the list node
  674.  
  675.       (cdr <expr>)  RETURN THE CDR OF A LIST NODE
  676.           <expr>      the list node
  677.           returns     the cdr of the list node
  678.  
  679.       (caar <expr>) == (car (car <expr>))
  680.       (cadr <expr>) == (car (cdr <expr>))
  681.       (cdar <expr>) == (cdr (car <expr>))
  682.       (cddr <expr>) == (cdr (cdr <expr>))
  683.  
  684.       (cons <expr1> <expr2>)  CONSTRUCT A NEW LIST NODE
  685.           <expr1>     the car of the new list node
  686.           <expr2>     the cdr of the new list node
  687.           returns     the new list node
  688.  
  689.       (list <expr>...)  CREATE A LIST OF VALUES
  690.           <expr>      expressions to be combined into a list
  691.           returns     the new list
  692.  
  693.       (append <expr>...)  APPEND LISTS
  694.           <expr>      lists whose elements are to be appended
  695.           returns     the new list
  696.  
  697.       (reverse <expr>)  REVERSE A LIST
  698.           <expr>      the list to reverse
  699.           returns     a new list in the reverse order
  700.  
  701.       (last <list>)  RETURN THE LAST LIST NODE OF A LIST
  702.           <list>      the list
  703.           returns     the last list node in the list
  704.  
  705.       (member <expr> <list> [<key> <test>])  FIND AN EXPRESSION IN A LIST
  706.           <expr>      the expression to find
  707.           <list>      the list to search
  708.           <key>       the keyword :test or :test-not
  709.           <test>      the test function (defaults to eql)
  710.           returns     the remainder of the list starting with the expression
  711.  
  712.       (assoc <expr> <alist> [<key> <test>])  FIND AN EXPRESSION IN AN A-LIST
  713.           <expr>      the expression to find
  714.           <alist>     the association list
  715.           <key>       the keyword :test or :test-not
  716.           <test>      the test function (defaults to eql)
  717.           returns     the alist entry or nil
  718.  
  719.  
  720.  
  721.       XLISP: An Experimental Object Oriented Language                Page 19
  722.       LIST FUNCTIONS
  723.  
  724.  
  725.       (remove <expr> <list> [<key> <test>])  REMOVE AN EXPRESSION FROM A LIST
  726.           <expr>      the expression to delete
  727.           <list>      the list
  728.           <key>       the keyword :test or :test-not
  729.           <test>      the test function (defaults to eql)
  730.           returns     the list with the matching expressions deleted
  731.  
  732.       (length <expr>)  FIND THE LENGTH OF A LIST
  733.           <expr>      the list
  734.           returns     the length of the list
  735.  
  736.       (nth <n> <list>)  RETURN THE NTH ELEMENT OF A LIST
  737.           <n>         the number of the element to return (zero origin)
  738.           <list>      the list
  739.           returns     the nth element or nil if the list isn't that long
  740.  
  741.       (nthcdr <n> <list>)  RETURN THE NTH CDR OF A LIST
  742.           <n>         the number of the element to return (zero origin)
  743.           <list>      the list
  744.           returns     the nth cdr or nil if the list isn't that long
  745.  
  746.       (mapc <fcn> <list1>...<listn>)  APPLY FUNCTION TO SUCCESSIVE CARS
  747.           <fcn>       the function or function name
  748.           <list1..n>  a list for each argument of the function
  749.           returns     the first list of arguments
  750.  
  751.       (mapcar <fcn> <list1>...<listn>)  APPLY FUNCTION TO SUCCESSIVE CARS
  752.           <fcn>       the function or function name
  753.           <list1..n>  a list for each argument of the function
  754.           returns     the list of values returned by each function invocation
  755.  
  756.       (mapl <fcn> <list1>...<listn>)  APPLY FUNCTION TO SUCCESSIVE CDRS
  757.           <fcn>       the function or function name
  758.           <list1..n>  a list for each argument of the function
  759.           returns     the first list of arguments
  760.  
  761.       (maplist <fcn> <list1>...<listn>)  APPLY FUNCTION TO SUCCESSIVE CDRS
  762.           <fcn>       the function or function name
  763.           <list1..n>  a list for each argument of the function
  764.           returns     the list of values returned by each function invocation
  765.  
  766.  
  767.  
  768.       XLISP: An Experimental Object Oriented Language                Page 20
  769.       LIST FUNCTIONS
  770.  
  771.  
  772.       (subst <to> <from> <expr> [<key> <test>])  SUBSTITUTE EXPRESSIONS
  773.           <to>        the new expression
  774.           <from>      the old expression
  775.           <expr>      the expression in which to do the substitutions
  776.           <key>       the keyword :test or :test-not
  777.           <test>      the test function (defaults to eql)
  778.           returns     the expression with substitutions
  779.  
  780.       (sublis <alist> <expr> [<key> <test>])  SUBSTITUTE USING AN A-LIST
  781.           <alist>     the association list
  782.           <expr>      the expression in which to do the substitutions
  783.           <key>       the keyword :test or :test-not
  784.           <test>      the test function (defaults to eql)
  785.           returns     the expression with substitutions
  786.  
  787.  
  788.  
  789.       XLISP: An Experimental Object Oriented Language                Page 21
  790.       DESTRUCTIVE LIST FUNCTIONS
  791.  
  792.  
  793.       14.0  DESTRUCTIVE LIST FUNCTIONS
  794.  
  795.       (rplaca <list> <expr>)  REPLACE THE CAR OF A LIST NODE
  796.           <list>      the list node
  797.           <expr>      the new value for the car of the list node
  798.           returns     the list node after updating the car
  799.  
  800.       (rplacd <list> <expr>)  REPLACE THE CDR OF A LIST NODE
  801.           <list>      the list node
  802.           <expr>      the new value for the cdr of the list node
  803.           returns     the list node after updating the cdr
  804.  
  805.       (nconc <list>...)  DESTRUCTIVELY CONCATENATE LISTS
  806.           <list>      lists to concatenate
  807.           returns     the result of concatenating the lists
  808.  
  809.       (delete <expr> <list> [<key> <test>])  DELETE AN EXPRESSION FROM A LIST
  810.           <expr>      the expression to delete
  811.           <list>      the list
  812.           <key>       the keyword :test or :test-not
  813.           <test>      the test function (defaults to eql)
  814.           returns     the list with the matching expressions deleted
  815.  
  816.  
  817.  
  818.       XLISP: An Experimental Object Oriented Language                Page 22
  819.       PREDICATE FUNCTIONS
  820.  
  821.  
  822.       15.0  PREDICATE FUNCTIONS
  823.  
  824.       (atom <expr>)  IS THIS AN ATOM?
  825.           <expr>      the expression to check
  826.           returns     t if the value is an atom, nil otherwise
  827.  
  828.       (symbolp <expr>)  IS THIS A SYMBOL?
  829.           <expr>      the expression to check
  830.           returns     t if the expression is a symbol, nil otherwise
  831.  
  832.       (numberp <expr>)  IS THIS A NUMBER?
  833.           <expr>      the expression to check
  834.           returns     t if the expression is a symbol, nil otherwise
  835.  
  836.       (null <expr>)  IS THIS AN EMPTY LIST?
  837.           <expr>      the list to check
  838.           returns     t if the list is empty, nil otherwise
  839.  
  840.       (not <expr>)  IS THIS FALSE?
  841.           <expr>      the expression to check
  842.           return      t if the expression is nil, nil otherwise
  843.  
  844.       (listp <expr>)  IS THIS A LIST?
  845.           <expr>      the expression to check
  846.           returns     t if the value is a list node or nil, nil otherwise
  847.  
  848.       (consp <expr>)  IS THIS A NON-EMPTY LIST?
  849.           <expr>      the expression to check
  850.           returns     t if the value is a list node, nil otherwise
  851.  
  852.       (boundp <sym>)  IS THIS A BOUND SYMBOL?
  853.           <sym>       the symbol
  854.           returns     t if a value is bound to the symbol, nil otherwise
  855.  
  856.  
  857.  
  858.       XLISP: An Experimental Object Oriented Language                Page 23
  859.       PREDICATE FUNCTIONS
  860.  
  861.  
  862.       (minusp <expr>)  IS THIS NUMBER NEGATIVE?
  863.           <expr>      the number to test
  864.           returns     t if the number is negative, nil otherwise
  865.  
  866.       (zerop <expr>)  IS THIS NUMBER ZERO?
  867.           <expr>      the number to test
  868.           returns     t if the number is zero, nil otherwise
  869.  
  870.       (plusp <expr>)  IS THIS NUMBER POSITIVE?
  871.           <expr>      the number to test
  872.           returns     t if the number is positive, nil otherwise
  873.  
  874.       (evenp <expr>)  IS THIS NUMBER EVEN?
  875.           <expr>      the number to test
  876.           returns     t if the number is even, nil otherwise
  877.  
  878.       (oddp <expr>)  IS THIS NUMBER ODD?
  879.           <expr>      the number to test
  880.           returns     t if the number is odd, nil otherwise
  881.  
  882.       (eq <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  883.           <expr1>     the first expression
  884.           <expr2>     the second expression
  885.           returns     t if they are equal, nil otherwise
  886.  
  887.       (eql <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  888.                               (WORKS WITH NUMBERS AND STRINGS)
  889.           <expr1>     the first expression
  890.           <expr2>     the second expression
  891.           returns     t if they are equal, nil otherwise
  892.  
  893.       (equal <expr1> <expr2>)  ARE THE EXPRESSIONS EQUAL?
  894.           <expr1>     the first expression
  895.           <expr2>     the second expression
  896.           returns     t if they are equal, nil otherwise
  897.  
  898.  
  899.  
  900.       XLISP: An Experimental Object Oriented Language                Page 24
  901.       CONTROL FUNCTIONS
  902.  
  903.  
  904.       16.0  CONTROL FUNCTIONS
  905.  
  906.       (cond <pair>...)  EVALUATE CONDITIONALLY
  907.           <pair>      pair consisting of:
  908.                           (<pred> <expr>...)
  909.                         where
  910.                           <pred>      is a predicate expression
  911.                           <expr>      evaluated if the predicate
  912.                                       is not nil
  913.           returns     the value of the first expression whose predicate
  914.                       is not nil
  915.  
  916.       (and <expr>...)  THE LOGICAL AND OF A LIST OF EXPRESSIONS
  917.           <expr>...   the expressions to be ANDed
  918.           returns     nil if any expression evaluates to nil,
  919.                       otherwise the value of the last expression
  920.                       (evaluation of expressions stops after the first
  921.                        expression that evaluates to nil)
  922.  
  923.       (or <expr>...)  THE LOGICAL OR OF A LIST OF EXPRESSIONS
  924.           <expr>...   the expressions to be ORed
  925.           returns     nil if all expressions evaluate to nil,
  926.                       otherwise the value of the first non-nil expression
  927.                       (evaluation of expressions stops after the first
  928.                        expression that does not evaluate to nil)
  929.  
  930.       (if <texpr> <expr1> [<expr2>])  EXECUTE EXPRESSIONS CONDITIONALLY
  931.           <texpr>     the test expression
  932.           <expr1>     the expression to be evaluated if texpr is non-nil
  933.           <expr2>     the expression to be evaluated if texpr is nil
  934.           returns     the value of the selected expression
  935.  
  936.       (let (<binding>...) <expr>...)  BIND SYMBOLS AND EVALUATE EXPRESSIONS
  937.       (let* (<binding>...) <expr>...)  LET WITH SEQUENTIAL BINDING
  938.           <binding>   the variable bindings each of which is either:
  939.                       1)  a symbol (which is initialized to nil)
  940.                       2)  a list whose car is a symbol and whose cadr
  941.                               is an initialization expression
  942.           <expr>...   the expressions to be evaluated
  943.           returns     the value of the last expression
  944.  
  945.       (catch <sym> [<expr>]...)  EVALUATE EXPRESSIONS AND CATCH THROWS
  946.           <sym>       the catch tag
  947.           <expr>...   expressions to evaluate
  948.           returns     the value of the last expression the throw expression
  949.  
  950.       (throw <sym> [<expr>])  THROW TO A CATCH
  951.           <sym>       the catch tag
  952.           <expr>      the value for the catch to return (defaults to nil)
  953.           returns     never returns
  954.  
  955.  
  956.  
  957.       XLISP: An Experimental Object Oriented Language                Page 25
  958.       LOOPING FUNCTIONS
  959.  
  960.  
  961.       17.0  LOOPING FUNCTIONS
  962.  
  963.       (do ([<binding>]...) (<texpr> [<rexpr>]...) [<expr>]...)
  964.       (do* ([<binding>]...) (<texpr> [<rexpr>]...) [<expr>]...)
  965.           <binding>   the variable bindings each of which is either:
  966.                       1)  a symbol (which is initialized to nil)
  967.                       2)  a list of the form: (<sym> <init> [<step>])
  968.                           where:
  969.                               <sym>  is the symbol to bind
  970.                               <init> is the initial value of the symbol
  971.                               <step> is a step expression
  972.           <texpr>     the termination test expression
  973.           <rexpr>...  result expressions (the default is nil)
  974.           <expr>...   the body of the loop (treated like an implicit prog)
  975.           returns     the value of the last result expression
  976.  
  977.       (dolist (<sym> <expr> [<rexpr>]) [<expr>]...)  LOOP THROUGH A LIST
  978.           <sym>       the symbol to bind to each list element
  979.           <expr>      the list expression
  980.           <rexpr>     the result expression (the default is nil)
  981.           <expr>...   the body of the loop (treated like an implicit prog)
  982.  
  983.       (dotimes (<sym> <expr> [<rexpr>]) [<expr>]...)  LOOP FROM ZERO TO N-1
  984.           <sym>       the symbol to bind to each value from 0 to n-1
  985.           <expr>      the number of times to loop
  986.           <rexpr>     the result expression (the default is nil)
  987.           <expr>...   the body of the loop (treated like an implicit prog)
  988.  
  989.  
  990.  
  991.       XLISP: An Experimental Object Oriented Language                Page 26
  992.       THE PROGRAM FEATURE
  993.  
  994.  
  995.       18.0  THE PROGRAM FEATURE
  996.  
  997.       (prog (<binding>...) [<expr>]...)  THE PROGRAM FEATURE
  998.       (prog* (<binding>...) [<expr>]...)  PROG WITH SEQUENTIAL BINDING
  999.           <binding>   the variable bindings each of which is either:
  1000.                       1)  a symbol (which is initialized to nil)
  1001.                       2)  a list whose car is a symbol and whose cadr
  1002.                               is an initialization expression
  1003.           <expr>      expressions to evaluate or tags (symbols)
  1004.           returns     nil or the argument passed to the return function
  1005.  
  1006.       (go <sym>)  GO TO A TAG WITHIN A PROG CONSTRUCT
  1007.           <sym>       the tag (quoted)
  1008.           returns     never returns
  1009.  
  1010.       (return [<expr>])  CAUSE A PROG CONSTRUCT TO RETURN A VALUE
  1011.           <expr>      the value (defaults to nil)
  1012.           returns     never returns
  1013.  
  1014.       (prog1 <expr1> [<expr>]...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  1015.           <expr1>     the first expression to evaluate
  1016.           <expr>...   the remaining expressions to evaluate
  1017.           returns     the value of the first expression
  1018.  
  1019.       (prog2 <expr1> <expr2> [<expr>]...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  1020.           <expr1>     the first expression to evaluate
  1021.           <expr2>     the second expression to evaluate
  1022.           <expr>...   the remaining expressions to evaluate
  1023.           returns     the value of the second expression
  1024.  
  1025.       (progn [<expr>]...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  1026.           <expr>...   the expressions to evaluate
  1027.           returns     the value of the last expression (or nil)
  1028.  
  1029.  
  1030.  
  1031.       XLISP: An Experimental Object Oriented Language                Page 27
  1032.       DEBUGGING AND ERROR HANDLING
  1033.  
  1034.  
  1035.       19.0  DEBUGGING AND ERROR HANDLING
  1036.  
  1037.       (error <emsg> [<arg>])  SIGNAL A NON-CORRECTABLE ERROR
  1038.           <emsg>      the error message string
  1039.           <arg>       the argument expression (printed after the message)
  1040.           returns     never returns
  1041.  
  1042.       (cerror <cmsg> <emsg> [<arg>])  SIGNAL A CORRECTABLE ERROR
  1043.           <cmsg>      the continue message string
  1044.           <emsg>      the error message string
  1045.           <arg>       the argument expression (printed after the message)
  1046.           returns     nil when continued from the break loop
  1047.  
  1048.       (break [<bmsg> [<arg>]])  ENTER A BREAK LOOP
  1049.           <bmsg>      the break message string (defaults to "**BREAK**")
  1050.           <arg>       the argument expression (printed after the message)
  1051.           returns     nil when continued from the break loop
  1052.  
  1053.       (errset <expr> [<pflag>])  TRAP ERRORS
  1054.           <expr>      the expression to execute
  1055.           <pflag>     flag to control printing of the error message
  1056.           returns     the value of the last expression consed with nil
  1057.                       or nil on error
  1058.  
  1059.       (baktrace [<n>])  PRINT N LEVELS OF TRACE BACK INFORMATION
  1060.           <n>         the number of levels (defaults to all levels)
  1061.           returns     nil
  1062.  
  1063.       (evalhook <expr> <ehook> <ahook>)  EVALUATE AN EXPRESSION WITH HOOKS
  1064.           <expr>      the expression to evaluate
  1065.           <ehook>     the value for *evalhook*
  1066.           <ahook>     the value for *applyhook*
  1067.           returns     the result of evaluating the expression
  1068.  
  1069.  
  1070.  
  1071.       XLISP: An Experimental Object Oriented Language                Page 28
  1072.       ARITHMETIC FUNCTIONS
  1073.  
  1074.  
  1075.       20.0  ARITHMETIC FUNCTIONS
  1076.  
  1077.       (+ <expr>...)  ADD A LIST OF NUMBERS
  1078.           <expr>...   the numbers
  1079.           returns     the result of the addition
  1080.  
  1081.       (- <expr>...)  SUBTRACT A LIST OF NUMBERS OR NEGATE A SINGLE NUMBER
  1082.           <expr>...   the numbers
  1083.           returns     the result of the subtraction
  1084.  
  1085.       (* <expr>...)  MULTIPLY A LIST OF NUMBERS
  1086.           <expr>...   the numbers
  1087.           returns     the result of the multiplication
  1088.  
  1089.       (/ <expr>...)  DIVIDE A LIST OF NUMBERS
  1090.           <expr>...   the numbers
  1091.           returns     the result of the division
  1092.  
  1093.       (1+ <expr>)  ADD ONE TO A NUMBER
  1094.           <expr>      the number
  1095.           returns     the number plus one
  1096.  
  1097.       (1- <expr>)  SUBTRACT ONE FROM A NUMBER
  1098.           <expr>      the number
  1099.           returns     the number minus one
  1100.  
  1101.       (rem <expr>...)  REMAINDER OF A LIST OF NUMBERS
  1102.           <expr>...   the numbers
  1103.           returns     the result of the remainder operation
  1104.  
  1105.       (min <expr>...)  THE SMALLEST OF A LIST OF NUMBERS
  1106.           <expr>...   the expressions to be checked
  1107.           returns     the smallest number in the list
  1108.  
  1109.       (max <expr>...)  THE LARGEST OF A LIST OF NUMBERS
  1110.           <expr>...   the expressions to be checked
  1111.           returns     the largest number in the list
  1112.  
  1113.       (abs <expr>)  THE ABSOLUTE VALUE OF A NUMBER
  1114.           <expr>      the number
  1115.           returns     the absolute value of the number
  1116.  
  1117.  
  1118.  
  1119.       XLISP: An Experimental Object Oriented Language                Page 29
  1120.       BITWISE LOGICAL FUNCTIONS
  1121.  
  1122.  
  1123.       21.0  BITWISE LOGICAL FUNCTIONS
  1124.  
  1125.       (bit-and <expr>...)  THE BITWISE AND OF A LIST OF NUMBERS
  1126.           <expr>      the numbers
  1127.           returns     the result of the and operation
  1128.  
  1129.       (bit-ior <expr...)  THE BITWISE INCLUSIVE OR OF A LIST OF NUMBERS
  1130.           <expr>      the numbers
  1131.           returns     the result of the inclusive or operation
  1132.  
  1133.       (bit-xor <expr...)  THE BITWISE EXCLUSIVE OR OF A LIST OF NUMBERS
  1134.           <expr>      the numbers
  1135.           returns     the result of the exclusive or operation
  1136.  
  1137.       (bit-not <expr>)  THE BITWISE NOT OF A NUMBER
  1138.           <expr>      the number
  1139.           returns     the bitwise inversion of number
  1140.  
  1141.  
  1142.  
  1143.       XLISP: An Experimental Object Oriented Language                Page 30
  1144.       RELATIONAL FUNCTIONS
  1145.  
  1146.  
  1147.       22.0  RELATIONAL FUNCTIONS
  1148.  
  1149.       The relational functions can be used to compare integers  or
  1150.       strings.   The  functions  '='  and '/=' can also be used to
  1151.       compare other types.  The result  of  these  comparisons  is
  1152.       computed the same way as for 'eq'.
  1153.  
  1154.       (< <e1> <e2>)  TEST FOR LESS THAN
  1155.           <e1>        the left operand of the comparison
  1156.           <e2>        the right operand of the comparison
  1157.           returns     the result of comparing <e1> with <e2>
  1158.  
  1159.       (<= <e1> <e2>)  TEST FOR LESS THAN OR EQUAL TO
  1160.           <e1>        the left operand of the comparison
  1161.           <e2>        the right operand of the comparison
  1162.           returns     the result of comparing <e1> with <e2>
  1163.  
  1164.       (= <e1> <e2>)  TEST FOR EQUAL TO
  1165.           <e1>        the left operand of the comparison
  1166.           <e2>        the right operand of the comparison
  1167.           returns     the result of comparing <e1> with <e2>
  1168.  
  1169.       (/= <e1> <e2>)  TEST FOR NOT EQUAL TO
  1170.           <e1>        the left operand of the comparison
  1171.           <e2>        the right operand of the comparison
  1172.           returns     the result of comparing <e1> with <e2>
  1173.  
  1174.       (>= <e1> <e2>)  TEST FOR GREATER THAN OR EQUAL TO
  1175.           <e1>        the left operand of the comparison
  1176.           <e2>        the right operand of the comparison
  1177.           returns     the result of comparing <e1> with <e2>
  1178.  
  1179.       (> <e1> <e2>)  TEST FOR GREATER THAN
  1180.           <e1>        the left operand of the comparison
  1181.           <e2>        the right operand of the comparison
  1182.           returns     the result of comparing <e1> with <e2>
  1183.  
  1184.  
  1185.  
  1186.       XLISP: An Experimental Object Oriented Language                Page 31
  1187.       STRING FUNCTIONS
  1188.  
  1189.  
  1190.       23.0  STRING FUNCTIONS
  1191.  
  1192.       (strcat <expr>...)  CONCATENATE STRINGS
  1193.           <expr>...   the strings to concatenate
  1194.           returns     the result of concatenating the strings
  1195.  
  1196.       (strlen <expr>)  COMPUTE THE LENGTH OF A STRING
  1197.           <expr>      the string
  1198.           returns     the length of the string
  1199.  
  1200.       (substr <expr> <sexpr> [<lexpr>]) EXTRACT A SUBSTRING
  1201.           <expr>      the string
  1202.           <sexpr>     the starting position
  1203.           <lexpr>     the length (default is rest of string)
  1204.           returns     substring starting at <sexpr> for <lexpr>
  1205.  
  1206.       (ascii <expr>)  NUMERIC VALUE OF CHARACTER
  1207.           <expr>      the string
  1208.           returns     the ascii code of the first character
  1209.  
  1210.       (chr <expr>)  CHARACTER EQUIVALENT OF ASCII VALUE
  1211.           <expr>      the numeric expression
  1212.           returns     a one character string whose first character is <expr>
  1213.  
  1214.       (atoi <expr>)  CONVERT AN ASCII STRING TO AN INTEGER
  1215.           <expr>      the string
  1216.           returns     the integer value of the string expression
  1217.  
  1218.       (itoa <expr>)  CONVERT AN INTEGER TO AN ASCII STRING
  1219.           <expr>      the integer
  1220.           returns     the string representation of the integer value
  1221.  
  1222.  
  1223.  
  1224.       XLISP: An Experimental Object Oriented Language                Page 32
  1225.       INPUT/OUTPUT FUNCTIONS
  1226.  
  1227.  
  1228.       24.0  INPUT/OUTPUT FUNCTIONS
  1229.  
  1230.       (read [<source> [<eof>]])  READ AN XLISP EXPRESSION
  1231.           <source>    the input source (default is standard input)
  1232.           <eof>       the value to return on end of file (default is nil)
  1233.           returns     the expression read
  1234.  
  1235.       (print <expr> [<sink>])  PRINT A LIST OF VALUES ON A NEW LINE
  1236.           <expr>      the expressions to be printed
  1237.           <sink>      the output sink (default is standard output)
  1238.           returns     nil
  1239.  
  1240.       (prin1 <expr> [<sink>])  PRINT A LIST OF VALUES
  1241.           <expr>      the expressions to be printed
  1242.           <sink>      the output sink (default is standard output)
  1243.           returns     nil
  1244.  
  1245.       (princ <expr> [<sink>])  PRINT A LIST OF VALUES WITHOUT QUOTING
  1246.           <expr>      the expressions to be printed
  1247.           <sink>      the output sink (default is standard output)
  1248.           returns     nil
  1249.  
  1250.       (terpri [<sink>])  TERMINATE THE CURRENT PRINT LINE
  1251.           <sink>      the output sink (default is standard output)
  1252.           returns     nil
  1253.  
  1254.       (flatsize <expr>)  LENGTH OF PRINTED REPRESENTATION USING PRIN1
  1255.           <expr>      the expression
  1256.           returns     the length
  1257.  
  1258.       (flatc <expr>)  LENGTH OF PRINTED REPRESENTATION USING PRINC
  1259.           <expr>      the expression
  1260.           returns     the length
  1261.  
  1262.       (explode <expr>)  CHARACTERS IN PRINTED REPRESENTATION USING PRIN1
  1263.           <expr>      the expression
  1264.           returns     the list of characters
  1265.  
  1266.       (explodec <expr>)  CHARACTERS IN PRINTED REPRESENTATION USING PRINC
  1267.           <expr>      the expression
  1268.           returns     the list of characters
  1269.  
  1270.       (maknam <list>)  BUILD AN UNINTERNED SYMBOL FROM A LIST OF CHARACTERS
  1271.           <list>      list of characters in symbol name
  1272.           returns     the symbol
  1273.  
  1274.       (implode <list>)  BUILD AN INTERNED SYMBOL FROM A LIST OF CHARACTERS
  1275.           <list>      list of characters in symbol name
  1276.           returns     the symbol
  1277.  
  1278.  
  1279.  
  1280.       XLISP: An Experimental Object Oriented Language                Page 33
  1281.       FILE I/O FUNCTIONS
  1282.  
  1283.  
  1284.       25.0  FILE I/O FUNCTIONS
  1285.  
  1286.       (openi <fname>)  OPEN AN INPUT FILE
  1287.           <fname>     the file name string
  1288.           returns     a file pointer
  1289.  
  1290.       (openo <fname>)  OPEN AN OUTPUT FILE
  1291.           <fname>     the file name string
  1292.           returns     a file pointer
  1293.  
  1294.       (close <fp>)  CLOSE A FILE
  1295.           <fp>        the file pointer
  1296.           returns     nil
  1297.  
  1298.       (read-char [<source>])  READ A CHARACTER FROM A FILE OR STREAM
  1299.           <source>    the input source (default is standard input)
  1300.           returns     the character (integer)
  1301.  
  1302.       (peek-char [<flag> [<source>]])  PEEK AT THE NEXT CHARACTER
  1303.           <flag>      flag for skipping white space (default is nil)
  1304.           <source>    the input source (default is standard input)
  1305.           returns     the character (integer)
  1306.  
  1307.       (write-char <ch> [<sink>])  WRITE A CHARACTER TO A FILE OR STREAM
  1308.           <ch>        the character to put (integer)
  1309.           <sink>      the output sink (default is standard output)
  1310.           returns     the character (integer)
  1311.  
  1312.       (readline [<source>])  READ A LINE FROM A FILE OR STREAM
  1313.           <source>    the input source (default is standard input)
  1314.           returns     the input string
  1315.  
  1316.  
  1317.  
  1318.       XLISP: An Experimental Object Oriented Language                Page 34
  1319.       SYSTEM FUNCTIONS
  1320.  
  1321.  
  1322.       26.0  SYSTEM FUNCTIONS
  1323.  
  1324.       (load <fname> [<vflag> [<pflag>]])  LOAD AN XLISP SOURCE FILE
  1325.           <fname>     the filename string (".lsp" is appended)
  1326.           <vflag>     the verbose flag (default is t)
  1327.           <pflag>     the print flag (default is nil)
  1328.           returns     the filename
  1329.  
  1330.       (gc)  FORCE GARBAGE COLLECTION
  1331.           returns     nil
  1332.  
  1333.       (expand <num>)  EXPAND MEMORY BY ADDING SEGMENTS
  1334.           <num>       the number of segments to add
  1335.           returns     the number of segments added
  1336.  
  1337.       (alloc <num>)  CHANGE NUMBER OF NODES TO ALLOCATE IN EACH SEGMENT
  1338.           <num>       the number of nodes to allocate
  1339.           returns     the old number of nodes to allocate
  1340.  
  1341.       (mem)  SHOW MEMORY ALLOCATION STATISTICS
  1342.           returns     nil
  1343.  
  1344.       (type <expr>)  RETURNS THE TYPE OF THE EXPRESSION
  1345.           <expr>      the expression to return the type of
  1346.           returns     nil if the value is nil otherwise one of the symbols:
  1347.                           SYM   for symbols
  1348.                           OBJ   for objects
  1349.                           LIST  for list nodes
  1350.                           SUBR  for subroutine nodes with evaluated arguments
  1351.                           FSUBR for subroutine nodes with unevaluated arguments
  1352.                           STR   for string nodes
  1353.                           INT   for integer nodes
  1354.                           FPTR  for file pointer nodes
  1355.  
  1356.       (exit)  EXIT XLISP
  1357.           returns     never returns
  1358.  
  1359.